package com.qf.microuser.point.service.impl;

import com.qf.common.core.entity.PointInfo;
import com.qf.common.core.entity.PointRule;
import com.qf.common.core.util.UserUtils;
import com.qf.microuser.point.mapper.PointInfoMapper;
import com.qf.microuser.point.service.PointInfoService;
import com.qf.microuser.point.service.PointRuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 天--道--酬--勤
 *
 * @author LiangGaoQiang
 * @ClassName PointRuleServiceImpl
 * @Date: 2025/5/28 14:32
 * @Description: 描述
 */
@Service
public class PointInfoServiceImpl implements PointInfoService {
    @Resource
    private PointInfoMapper pointInfoMapper;

    @Resource
    private PointRuleService pointRuleService;

    @Override
    public Boolean addRemotePoint(Integer pointType) {
        PointRule pointRule = pointRuleService.getPointByType(pointType);

        Integer uid = UserUtils.getUid();
        // 判断空
        if (pointRule != null) {
            PointInfo  pointInfo = new PointInfo();
            pointInfo.setUid(uid);
            pointInfo.setPointType(pointType);
            pointInfo.setPoint(pointRule.getPoint());
            pointInfoMapper.insert(pointInfo);
            return true;
        }
        return false;
    }
}
